
package com.gitee.jmash.websocket.client;

import com.gitee.jmash.common.grpc.client.GrpcChannel;
import com.gitee.jmash.rbac.client.RbacClient;
import jakarta.enterprise.inject.Produces;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.inject.Singleton;
import jmash.websocket.WebsocketGrpc;

/** Websocket Client . */
public class WebsocketClient {

  /** WebsocketBlockingStub. */
  public static WebsocketGrpc.WebsocketBlockingStub getWebsocketBlockingStub() {
    return WebsocketGrpc.newBlockingStub(WebsocketClientConfig.getManagedChannel()).withCallCredentials(GrpcChannel.getCallCredentials());
  }

  /** WebsocketFutureStub. */
  public static WebsocketGrpc.WebsocketFutureStub getWebsocketFutureStub() {
    return WebsocketGrpc.newFutureStub(WebsocketClientConfig.getManagedChannel()).withCallCredentials(GrpcChannel.getCallCredentials());
  }

  /** WebsocketStub. */
  public static WebsocketGrpc.WebsocketStub getWebsocketStub() {
    return WebsocketGrpc.newStub(WebsocketClientConfig.getManagedChannel()).withCallCredentials(GrpcChannel.getCallCredentials());
  }

  /**
   * WebsocketBlockingStub.
   */
  public static WebsocketGrpc.WebsocketBlockingStub getWebsocketSystemBlockingStub(String tenant) {
    return WebsocketGrpc.newBlockingStub(WebsocketClientConfig.getManagedChannel())
        .withCallCredentials(RbacClient.getSystemCredentials(tenant));
  }

  /**
   * WebsocketFutureStub.
   */
  public static WebsocketGrpc.WebsocketFutureStub getWebsocketSystemFutureStub(String tenant) {
    return WebsocketGrpc.newFutureStub(WebsocketClientConfig.getManagedChannel())
        .withCallCredentials(RbacClient.getSystemCredentials(tenant));
  }

  /**
   * WebsocketStub.
   */
  public static WebsocketGrpc.WebsocketStub getWebsocketSystemStub(String tenant) {
    return WebsocketGrpc.newStub(WebsocketClientConfig.getManagedChannel())
        .withCallCredentials(RbacClient.getSystemCredentials(tenant));
  }

}
